import axios from 'axios'
import storage from '@/utils/storage'
const service = axios.create({
    baseURL: process.env.NODE_ENV == 'production' ? 'http://192.168.110.132:8080/' : '/',
    timeout: 1000000 // request timeout
})


service.interceptors.request.use(
    config => {
      config.headers['token'] = 'c26aaf2a5bd4a3c495cbf1a1290a0b57' // 让每个请求携带自定义token 请根据实际情况自行修改

        return config
    },
    error => {
        Promise.reject(error)
    }
)

service.interceptors.response.use(
    response => {
      return Promise.resolve(response)

    },
    error => {
        // MessageBox.alert('请求错误，重新登录', '提示', {
        //     confirmButtonText: '确定',
        //     cancelButtonText: '取消',
        //     type: 'warning',
        //     center: true
        // }).then(() => {
        //     storage.remove("user");
        //     storage.remove("tree");
        //     delCookie("isLogin");
        //     router.replace({ path: "/login" })
        // })
    }
)

export default service;
